package com.company.demo.service;

import com.company.demo.bean.Student;
import com.company.demo.dao.IStudentDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class SomeServiceImpl implements ISomeService {

    @Autowired//dao 的依赖注入
    private IStudentDao dao;

    @Override
    //@Transactional //事务的注解
    public void addStudent(Student student){

        //插入时会发生回滚，无法插入到DB数据库中
        dao.insertStudent(student);

//        int i = 3/0;  //抛出异常语句
//        dao.insertStudent(student);
    }
}
